package cn.supuwoerc.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component("myAspect")
public class MyAspect {
    @Before("execution(public void cn.supuwoerc.aop.*.*(..))")
    public void before() {
        System.out.println("前置增强方法...");
    }
    @AfterReturning("execution(public void cn.supuwoerc.aop.*.*(..))")
    public void after() {
        System.out.println("后置增强方法...");
    }
    @Around("MyAspect.abc()")
    public Object surround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕前...");
        Object proceed = proceedingJoinPoint.proceed();   //正在执行的方法：proceedingJoinPoint
        System.out.println("环绕后...");
        return proceed;
    }
    @AfterThrowing("execution(public void cn.supuwoerc.aop.*.*(..))")
    public void throwErr() {
        System.out.println("异常抛出...");
    }
    @After("abc()")
    public void finallyFunc() {
        System.out.println("最终...");
    }
    @Pointcut("execution(public void cn.supuwoerc.aop.*.*(..))")
    public void abc(){}
}
